<!DOCTYPE html>
<html>
<head>
    <title>用户信息</title>
    <#include "/header.html">
    <style>
        .layui-form-label {
            width: 110px;
        }
    </style>
</head>
<body class="bg-white">

<div id="appMain">
</div>

<script type="text/html" id="userInfoTpl">
    <div class="layui-fluid">
        <div class="layui-row">
            <div class="layui-col-md5">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-word-aux">昵称：</label>
                    <div class="layui-form-mid">{{d.info.username}}</div>
                </div>
            </div>
            <div class="layui-col-md5">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-word-aux">手机号：</label>
                    <div class="layui-form-mid">{{d.info.mobile}}</div>
                </div>
            </div>
            <div class="layui-col-md2">
                {{# if(d.info.avatar != ''){ }}
                <img src="{{d.info.avatar}}" width="50" alt="">
                {{# } else { }}
                <img src="${request.contextPath}/statics/images/avatar.png" width="50" alt="">
                {{# } }}
            </div>
            <div class="layui-col-md5">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-word-aux">性别：</label>
                    <div class="layui-form-mid">
                        {{# if(d.info.gender == 1){ }} 男
                        {{# } else if(d.info.gender == 2){ }} 女
                        {{# } else { }} 未知
                        {{# } }}
                    </div>
                </div>
            </div>
            <div class="layui-col-md5">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-word-aux">状态：</label>
                    <div class="layui-form-mid">
                        {{# if(d.info.status == 1){ }} <span class="layui-badge layui-bg-green">启用</span>
                        {{# } else { }} <span class="layui-badge layui-bg-grey">禁用</span>
                        {{# } }}
                    </div>
                </div>
            </div>
            <div class="layui-col-md2">
                <div class="layui-form-mid">
                    {{# if(d.info.isSeller == 1){ }} <span class="layui-badge layui-bg-green">商家用户</span>
                    {{# } else { }} <span class="layui-badge layui-bg-grey">普通用户</span>
                    {{# } }}
                </div>
            </div>
            <div class="layui-col-md5">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-word-aux">注册时间：</label>
                    <div class="layui-form-mid">{{d.info.createTime}}</div>
                </div>
            </div>
            <div class="layui-col-md5">
                <div class="layui-form-item">
                    <label class="layui-form-label layui-word-aux">最后登录时间：</label>
                    <div class="layui-form-mid">
                        {{d.info.loginTime}}
                        {{# if(d.info.loginIp){ }} ({{d.info.loginIp}}) {{# } }}
                    </div>
                </div>
            </div>
        </div>
        <div class="layui-tab layui-tab-brief" style="padding: 25px;">
            <ul class="layui-tab-title">
                <li>地址列表</li>
            </ul>
            <div class="layui-tab-content" style="padding: 20px;">
                {{#  layui.each(d.addrs, function(index, addr){ }}
                <div class="layui-form-item">
                    <span class="layui-badge layui-bg-cyan">{{addr.tag}}</span>
                    <span style="margin: 0 10px;">{{addr.name}}（{{addr.gender==2?'女士':'先生'}}）{{addr.mobile}}</span>
                    <span class="layui-word-aux">{{addr.street}},</span>
                    <span class="layui-word-aux">({{addr.regionText}})</span>
                    <span class="layui-word-aux">
                        {{# if(addr.isDefault == 1){ }}<span class="layui-badge layui-bg-gray">默认地址</span>{{# } }}
                    </span>
                </div>
                {{#  }); }}
            </div>
        </div>
    </div>
</script>

<script type="text/javascript">
    layui.use(['form', 'laytpl', 'upload'], function () {
        var form = layui.form,
            laytpl = layui.laytpl,
            upload = layui.upload,
            $ = layui.$;

        var _parent = parent;
        if(_parent.formDataId > 0) {
            $.ajax({
                type: "POST",
                url: serverUrl('user/info/' + _parent.formDataId),
                success: function (result) {
                    if (result.code === 0) {
                        laytpl($("#userInfoTpl").html()).render(result, function(html){
                            $("#appMain").html(html);
                        });
                    }
                }
            });
        }

    });
</script>
</body>
</html>